package com.snts.synchronization.schema;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class SchemaUpdate {

	private String sql;
	private String name;

	public SchemaUpdate(String sql) {
		this(sql, null);
	}

	public SchemaUpdate(String sql, String name) {
		super();
		this.sql = sql;
		this.name = name;
	}

	public String getSql() {
		return sql;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return getSql();
	}

	public void apply(Connection conn) throws SQLException{
		Statement stmt=conn.createStatement();
		try {
			stmt.executeUpdate(sql);
		} finally {
			stmt.close();
		}
	}
	
}
